<?php 
$webroot="";
if(session::is_manager()==TRUE)
{
	require_once 'html/admintemplate.php';
}
else 
{
	require_once 'html/template.php';
}

?>

<table border="1" bordercolor="#F0FFFF" width="100%" height="100%">
<?php 
if(session::is_manager()==TRUE)
{
?>
<tr class="classmenu">
<td colspan=7>
Order History
</td>
</tr>
<tr>
<td colspan=7>
Pages: 
<?php
if($pagesnum-$Pages_id<5)
{
	$pageMax=$pagesnum;
}
else
{
	$pageMax=$Pages_id+5;
}

if($Pages_id<=5)
{
	$pageMin=1;
}
else
{
	$pageMin=$Pages_id-5;
}
$idPageNext=$Pages_id+1;
$idPageEnd=$pagesnum;
$idPageFirst=1;
echo "<a href=orderhistory.php?pagesid=$idPageFirst>First Page</a> ";
for($idpage=$pageMin;$idpage<=$pageMax;$idpage++)
{
	if($idpage==$Pages_id)
	{
		$Show="<b>$idpage</b>";
	}
	else 
	{
		$Show=$idpage;
	}
	echo "<a href=orderhistory.php?pagesid=$idpage>$Show </a>";
}
echo "<a href=orderhistory.php?pagesid=$idPageNext>Next Page</a> ";
echo "<a href=orderhistory.php?pagesid=$idPageEnd>Last Page</a>";
?>
</td>
</tr>
<tr class="classtopmenu">
<td>
Order
</td>
<td>
Time Order
</td>
<td>
UserName
</td>
<td>
Money
</td>
<td>
Refund
</td>
<td>
Plan
</td>
<td>
Check Cost 
</td>
</tr>

<?php
$i=($Pages_id-1)*40+1;
	foreach($GetOrderHistory as $ShowHistory)
	{
		
		$Js=$ShowHistory['userid'].",".$ShowHistory['orderid'];

		?>
		<tr>
		<td>
		<a href="javascript:viewoderhistory(<?php echo $Js;?>)" ><?php echo $i;?></a>
		</td>
		<td>
		<?php echo $ShowHistory['timeorder'];?>
		</td>
		
		<td>
		<?php echo $ShowHistory['username'];?>
		</td>
		
		<td>
		<?php echo $ShowHistory['money'];?>
		</td>
		
		<td>
		<?php echo $ShowHistory['refund'];?>
		</td>
		
		<td>
		<?php echo $ShowHistory['site'];?>
		</td>
		
		<td>
		<?php echo $ShowHistory['check'];?>
		</td>
		</tr>
		<tr >
	<td colspan=7 id="returnorderdetail<?php echo $ShowHistory['orderid'];?>" >
	</td>
	</tr>
		<?php 
		$i++;
	}
}
else if(session::is_member()==TRUE)
{
	?>
	<tr class="classmenu">
<td colspan=7>
Order History
</td>
</tr>
<tr>
<td colspan=7>
Pages: 
<?php 
if($pagesnum-$Pages_id<5)
{
	$pageMax=$pagesnum;
}
else
{
	$pageMax=$Pages_id+5;
}

if($Pages_id<=5)
{
	$pageMin=1;
}
else
{
	$pageMin=$Pages_id-5;
}
$idPageNext=$Pages_id+1;
$idPageEnd=$pagesnum;
$idPageFirst=1;
echo "<a href=orderhistory.php?pagesid=$idPageFirst>First Page</a> ";
for($idpage=$pageMin;$idpage<=$pageMax;$idpage++)
{
	if($idpage==$Pages_id)
	{
		$Show="<b>$idpage</b>";
	}
	else 
	{
		$Show=$idpage;
	}
	echo "<a href=orderhistory.php?pagesid=$idpage>$Show </a>";
}
echo "<a href=orderhistory.php?pagesid=$idPageNext>Next Page</a> ";
echo "<a href=orderhistory.php?pagesid=$idPageEnd>Last Page</a>";
?>
</td>
</tr>
<tr class="classtopmenu">
<td>
Order
</td>
<td>
Time Order
</td>
<td>
Money
</td>
<td>
Refund
</td>
<td>
Plan
</td>
<td>
Check Cost
</td>
</tr>
	<?php
	if(empty($GetOrderHistory))
	{
		?>
		<tr>
		<td colspan=6>
		You Do Not Have Order History
		</td>
		</tr>
		<?php
	}
	else 
	{
		$i=1;
		foreach($GetOrderHistory as $ShowHistory)
		{
			
		?>
		<tr>
		<?php 
		if($i==1)
		{
			?>
			<td>
		<a href="javascript:viewoderhistory(0,<?php echo $ShowHistory['orderid'];?>);" ><img src="images/new.gif" /><?php echo $ShowHistory['orderid'];?></a>
		</td>
			<?php 
		}
		else 
		{
			?>
			<td>
		<a href="javascript:viewoderhistory(0,<?php echo $ShowHistory['orderid'];?>);" ><?php echo $ShowHistory['orderid'];?></a>
		</td>
			<?php 
		}
		?>
		
		<td>
		<?php echo $ShowHistory['timeorder'];?>
		</td>
		<td>
		<?php echo $ShowHistory['money'];?>
		</td>
		<td>
		<?php echo $ShowHistory['refund'];?>
		</td>
		<td>
		<?php echo $ShowHistory['site'];?>
		</td>
		<td>
		<?php echo $ShowHistory['check'];?>
		</td>
		</tr>
		<tr >
	<td colspan=7 id="returnorderdetail<?php echo $ShowHistory['orderid'];?>" >
	</td>
	</tr>
		<?php 
		$i++;
		}
	}
}
?>
</table>
</div>